{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/common/daterangepicker-bs3.css" />
    <link rel="stylesheet" type="text/css" href="/css/mediation/caseallocate/index.css" />
<style>
.modal.in .modal-dialog{
    transform: translate(0,50%)!important;
}
</style>
{/block}
{block name="page_section"}
<div class="sessionPage">
  <div class="page-header">
    <div class="left">
      <span class="line"></span>
      <strong class="tit">修复批次</strong>
    </div>
  </div>
  <form class="small-style" method="get" action="" role="validform" enctype="multipart/form-data">
    <div class="form_row">
      <input type="hidden" name="is_show" class="showmoreishow" value="{if $is_show == 1}1{else}0{/if}">
      <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
      <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-4 control-label">修复运营商:</label>
          <div class="col-sm-7">
              <select class="form-control selectpicker"    title="请选择" name="repairType" id="repairType">
                  <option class="u144_input_option" {if !empty($query.repairType) &&  1 == $query.repairType}selected="selected"{/if} value="1">移动</option>
                  <option class="u144_input_option" {if !empty($query.repairType) &&  2 == $query.repairType}selected="selected"{/if} value="2">联通</option>
              </select>
          </div>
      </div>
      <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-4 control-label">运营商批次号:</label>
          <div class="col-sm-7">
              <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batchNo)}{$query.batchNo}{/if}" name="batchNo" id="batchNo" placeholder="请输入~">
          </div>
      </div>
      <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-4 control-label">批次状态:</label>
          <div class="col-sm-7">
              <select class="form-control selectpicker"    title="请选择" name="repairStatus" id="repairStatus">
                  {foreach from=$repairStatus key=key   item=info}
                  <option class="u144_input_option" {if !empty($query.repairStatus) &&  $key == $query.repairStatus}selected="selected"{/if} value="{$key}">{$info}</option>
                  {/foreach}
              </select>
          </div>
      </div>
      <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-4 control-label">创建人:</label>
          <div class="col-sm-7">
              <select class="form-control selectpicker"   title="请选择" name="creatId" id="creatId">
                  {foreach from=$mediator  item=info}
                  <option class="u144_input_option" {if !empty($query.creatId) &&  $info.id == $query.creatId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                  {/foreach}
              </select>
          </div>
      </div>
    </div>
    <div class="form_row">
      <div class="form-group col-lg-3 ui-select">
          <label class="col-sm-4 control-label">
              创建时间:
          </label>
          <div class="col-sm-7">
              <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
          </div>
      </div>
      <div class="form-group col-lg-3 ui-select">
          <label for="exampleInputName2"  class="col-sm-4 control-label">提交人:</label>
          <div class="col-sm-7">
              <select class="form-control selectpicker"   title="请选择" name="submitId" id="submitId">
                  {foreach from=$mediator  item=info}
                  <option class="u144_input_option" {if !empty($query.submitId) &&  $info.id == $query.submitId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                  {/foreach}
              </select>
          </div>
      </div>
      <div class="form-group col-lg-3 ui-select">
          <label class="col-sm-4 control-label">
              提交时间:
          </label>
          <div class="col-sm-7">
              <input data-ele="date" data-type="daterange" name="submit_add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.submit_add_begin_end)}{$smarty.get.submit_add_begin_end}{/if}" autocomplete="off"/>
          </div>
      </div>
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">批次名称:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batchName)}{$query.batchName}{/if}" name="batchName" id="batchName" placeholder="可模糊查询，请输入~">
            </div>
        </div>
    </div>
    <div class="form_row">
        <div class="form-group col-lg-3 ui-select">
          <div class="col-lg-4" style="float: right;">
              <button class="btn btn-primary col-lg-8 shousuoBtn "><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
          </div>
          <div class="col-lg-4">
              <a type="button" href="/repairbatch" class="btn btn-default col-lg-8 "><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
          </div>
      </div>
        <div class="ui-select"></div>
        <div class="ui-select"></div>
        <div class="ui-select"></div>
    </div>
  </form>
  <div style="width: 95%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow-x: scroll;">
      <table class=" table table-striped table-bordered table-hover text-nowrap" id="tab">
          <thead>
              <tr>
                  <th>批次id</th>
                  <th>批次名称</th>
                  <th>运营商批次号</th>
                  <th>运营商</th>
                  <th>批次状态</th>
                  <th>状态描述</th>
                  <th>创建人</th>
                  <th>创建时间</th>
                  <th>提交人</th>
                  <th>提交时间</th>
                  <th>完成时间</th>
                  <th>修复数量</th>
                  <th>成功/失败</th>
                  <th>修复率</th>
                  <th class="fix-ele">操作</th>
          </thead>
          <tbody>
              {foreach from=$arrList item=item name=foo}
              <tr>
                  <td>{$item.id}</td>
                  <td>{if empty($item.batchName)}--{else}{$item.batchName}{/if}</td>
                  <td>{if empty($item.batchNo)}--{else}{$item.batchNo}{/if}</td>
                  <td>{if $item.repairType == 1}移动{else}联通{/if}</td>
                  <td>{$repairStatus[$item.repairStatus]}</td>
                  <td>{if empty($item.desc)}--{else}<span style="color: red">{$item.desc}</span>{/if}</td>
                  <td>{if empty($item.creatName)}--{else}{$item.creatName}{/if}</td>
                  <td>{if empty($item.creatTime)}--{else}{$item.creatTime|date_format:"%Y-%m-%d %H:%M:%S"}{/if}</td>
                  <td>{if empty($item.submitName)}--{else}{$item.submitName}{/if}</td>
                  <td>{if empty($item.submitTime)}--{else}{$item.submitTime|date_format:"%Y-%m-%d %H:%M:%S"}{/if}</td>
                  <td>{if empty($item.completeTime)}--{else}{$item.completeTime|date_format:"%Y-%m-%d %H:%M:%S"}{/if}</td>
                  <td>{$item.repairNum}</td>
                  <td>{if $item.repairStatus == 4}{$item.successNum} / {$item.repairNum - $item.successNum}{else}--{/if}</td>
                  <td>{$item.rate}%</td>
                  <td class="text-nowrap fix-ele">
                      <a href="/repairbatch/batchDetail?batchId={$item.id}">修复详情</a>
                       |
                      {if $item.repairStatus == 2}
                      <a class="confirmreapir" href="javascript:;" data-id="{$item.id}">确认修复</a>
                      {else}
                      <font color="#8c8c8c">确认修复</font>
                      {/if}
                       |
                      {if $item.repairStatus <= 2}
                      <a data-type="1" data-toggle="modal" data-id="{$item.id}" data-target="#confirm"  id='bash_delete'>删除</a>
                      {else}
                      <font color="#8c8c8c">删除</font>
                      {/if}
                  </td>
              </tr>
              {/foreach}
          </tbody>
      </table>
  </div>
  <input type="hidden" value="" id="allocate_type">
  <input type="hidden" value="" id="allocate_ids">

  <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
      {include file="base/pagenav.html"  action="/repairbatch/index" pagenum=$curPageNum inline}
      <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
          <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
          <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
          <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
          <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
      </select>
      <span style="float:right;">共 {$totalnum} 条</span>
  </div>
    <div class="modal fade" id="confirm" tabindex="-1" role="dialog" aria-labelledby="confirmLabel">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <form  class="form-inline">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="confirmLabel">操作提示</h4>
                    </div>
                    <div class="modal-body">
                        <span class="dialog-tips">您确删除该批次吗？</span>
                        <input type="hidden" value=""  id="deleteRecordId">

                    </div>
                    <div class="modal-footer">
                        <button type="button" id="confirmdel"  class="btn btn-primary">确定</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
{/block}
{block name="page_scripts"}
    <script type="text/javascript">
        lockfas = false;
        $(".caseallocateall").on("click",function(){
            var arrbtn = [];
            $(".j-check:checked").each(function (index, ele) {
                //遍历所有复选框，然后取值进行 !非操作
                if ($(this).prop("checked")) {
                    arrbtn.push($(this).val());
                }
            })
            if(arrbtn.length==0){
                toastr.error('请选择案件');
                return false;
            }
            var ids=arrbtn.toString();
            $("#allocate_ids").val(ids);
            $("#allocate_type").val($(this).attr('allocate-type'));

        });

        $(".caseallocateone").on("click",function(){
            var ids=$(this).attr('data-id');
            $("#allocate_ids").val(ids);
            $("#allocate_type").val(1);

        });
        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        $('body')
            .on('change','#paglimit', function(){
            console.log()
            var mediationOrganId = GetQueryString('mediationOrganId');
            var paglimit = GetQueryString('limit');
            var val =  $(this).val();
            if(!mediationOrganId){
                if(!paglimit){
                    window.location = window.location.href+'?'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
        })
            .on('click','.confirmreapir', function(){
                var that=$(this);
                $.confirm({
                    title: '注意！',
                    content: '确认提交复联，完成后会对成功数据收费！',
                    confirmButton: '确定',
                    cancelButton: '取消',
                    confirm: function(){
                        $.ajax({
                            url:"/repairbatch/submitISP",
                            method:"post",
                            data:{
                                id: that.attr('data-id'),
                            },
                            success:function(res){
                                if(res.code==200){
                                    toastr.success("提交成功");
                                }else{
                                    toastr.error(res.message);
                                }
                                setTimeout(function(){
                                    window.location.reload();
                                },2000)
                            },
                            error: function(err){
                                toastr.error('网络错误,请稍后重试');
                            }
                        })
                    },
                    cancel: function(){
                        // alert('Canceled!')
                    }
                });
            })
            .on('click','#bash_delete', function(){
                $("#deleteRecordId").val($(this).attr('data-id'));
            })
            .on('click','#confirmdel', function(){
                if(lockfas)return;
                lockfas = true;
                $.ajax({
                    url:"/repairbatch/deleteRecord",
                    method:"post",
                    data:{
                        recordId: $("#deleteRecordId").val(),
                    },
                    success:function(res){
                        if(res.code==200){
                            toastr.success(res.message);
                            setTimeout(function(){
                                window.location.href = window.location.href;
                            },1500)
                        }else{
                            toastr.error(res.message);
                        }
                        lockfas = false;
                    },
                    error: function(err){
                        lockfas = false;
                        toastr.error('网络错误,请稍后重试');
                    }
                })
            })


    </script>
{/block}
